Skip to content

docs: explain IPv6 localhost resolution for published sandbox ports#25200

Merged
dvdksn merged 1 commit into
docker:mainfrom
robmry:docs/sandbox-ports-ipv6
May 29, 2026
Merged

docs: explain IPv6 localhost resolution for published sandbox ports#25200
dvdksn merged 1 commit into
docker:mainfrom
robmry:docs/sandbox-ports-ipv6

Conversation

@robmry
Copy link
Copy Markdown
Contributor

@robmry robmry commented May 28, 2026

Description

Documents a gotcha with sbx ports --publish where clients resolving localhost to IPv6 fail with "connection reset by peer", even thoughhttp://127.0.0.1:<port>/ works.

When no host IP is given to --publish, the host listener binds to both 127.0.0.1 and ::1. Many dev servers (Vite, code-server with --bind-addr 0.0.0.0:8080, etc.) only listen on IPv4 inside the sandbox, so any client that picks IPv6 for localhost hits a dead end.

Two changes to the bullet list under Accessing services in the sandbox:

  • Reframed the existing "bind to 0.0.0.0" bullet to also mention [::] for dual-stack listeners.
  • Added a new bullet describing the IPv6-localhost failure mode and the two fixes: bind the sandboxed service to [::], or restrict the published port with /tcp4 (or /tcp6).

Context: internal Slack thread where two users hit this independently.

Document the gotcha where `--publish` listens on both `127.0.0.1` and
`::1` while many dev servers bind only to IPv4 — clients resolving
`localhost` to IPv6 then fail with "connection reset by peer".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@robmry robmry requested a review from dvdksn as a code owner May 28, 2026 17:39
@netlify
Copy link
Copy Markdown

netlify Bot commented May 28, 2026

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 348ebe4
🔍 Latest deploy log https://app.netlify.com/projects/docsdocker/deploys/6a187db764338e0007f1724e
😎 Deploy Preview https://deploy-preview-25200--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟡 NEEDS ATTENTION


- **Services must bind to `0.0.0.0`** — a service listening on `127.0.0.1`
inside the sandbox won't be reachable through a published port. Most dev
- **Services must listen on all interfaces** — a service listening only on
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] Prohibited **Term** — Description list format in new bullets

Both new bullets use the **Bold term** — description pattern that the Docker style guide explicitly prohibits in lists (STYLE.md: "Avoid marketing-style list formatting — Don't use 'Term - Description' format, which reads like marketing copy"). The same rule also means bold should only appear on UI elements (buttons, menus, field labels), not on technical concept labels.

The existing bullets in this list already have this pattern, but this PR adds two more instances. Consider reformatting as plain descriptive bullets — for example:

- Services must listen on all interfaces: a service listening only on
  `127.0.0.1` inside the sandbox won't be reachable through a published port.
  Bind to `0.0.0.0` for IPv4, or `[::]` to accept both IPv4 and IPv6. Most dev
  servers default to `127.0.0.1`, so you'll usually need to pass a flag like
  `--host 0.0.0.0` or `--host '[::]'` when starting them.
- `localhost` on the host can resolve to IPv6: by default, `--publish`
  listens on both `127.0.0.1` and `::1`. ...

Or use plain prose. Note: the pre-existing bullets (Not persistent, No create-time flag, Unpublish requires the host port) have the same formatting issue — it may be worth fixing those at the same time.

@dvdksn dvdksn merged commit 741c874 into docker:main May 29, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants